package com.zzb.framework.query.sqlbuilder.postgres;

import com.zzb.framework.query.sqlbuilder.PagionageSqlBuilder;

/**
 * Created by zhangzhenbin on 18-1-17.
 */
public class PostgresPagionageSqlBuilder implements PagionageSqlBuilder {
    @Override
    public String build(Integer page, Integer pageSize) {
        //分页
        StringBuilder limitStringBuilder = new StringBuilder();
        if (page != null && pageSize != null && pageSize > 0) {
            int offset = (page - 1) * pageSize;
            limitStringBuilder.append(" limit ").append(pageSize).append(" offset ").append(offset);
        }
        return limitStringBuilder.toString();
    }
}
